<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\Authenticatable as AuthenticableTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class DawnUser extends Model implements Authenticatable
{
    use HasFactory, AuthenticableTrait;
    public $timestamps = false; // 禁用时间戳 这样就不会更新 created_at 和 updated_at 字段。
    protected $table = 'dawn_users';
    protected $primaryKey = 'dawn_id';
    protected $fillable = [
        'dawn_name',
        'dawn_password',
        'dawn_createTime',
        'dawn_lastTime',
        'dawn_updatatime',
        'dawn_Status'
    ];

    public function getAuthPassword()
    {
        return $this->dawn_password;
    }

    public function getUsernameForPasswordBroker()
    {
        return $this->dawn_name;
    }

    /**
     * 获取关联的智慧教育用户信息
     */
    public function zhjyUser()
    {
        return $this->hasOne(DawnZhjyUser::class, 'dawn_id', 'dawn_id');
    }
}
